<?php
include 'includes/utilities.php';
$link = OpenDB();
$search = mysql_real_escape_string($_GET["q"]);
$search = str_ireplace ( "á","%" , $search);
$search = str_ireplace ( "é","%" , $search);
$search = str_ireplace ( "í","%" , $search);
$search = str_ireplace ( "ó","%" , $search);
$search = str_ireplace ( "ú","%" , $search);
$search = str_ireplace ( "ñ","%" , $search);
$query = "select id_obra_social as id, nombre from obra_social where nombre like '%".$search."%'";
$obrasSociales = GetSQL($query);
$valores = "";
foreach($obrasSociales as $obraSocial)
{
    $valores .=  '{"id":"'.$obraSocial["id"].'", "name":"'.$obraSocial["nombre"].'"},';
}
$valores = rtrim($valores, ",");
?>
[<?= $valores ?>]